﻿<runtime:VisualPart
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:runtime="clr-namespace:ViewOnCore.Visual;assembly=ViewOnCore"
	xmlns:igWindows="http://infragistics.com/Windows"
    xmlns:igDP="http://infragistics.com/DataPresenter"
    xmlns:igEditors="http://infragistics.com/Editors"
	xmlns:wpf="clr-namespace:ViewOnCore.Helper.WPF;assembly=ViewOnCore"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:properties="clr-namespace:RadioPlayerAddIn.Properties"
	mc:Ignorable="d"
    x:Class="RadioPlayerAddIn.RadioPlayer"
	IsEnabled="True"
	Focusable="False">
	<runtime:VisualPart.Resources>

		<!-- Context menu -->
		<ContextMenu x:Key="RadioPartContextMenu">
			<MenuItem Header="{x:Static properties:Globalization.RadioPart_ContextMenu_Play}" Click="contextMenuPlay_Click"/>
		</ContextMenu>
		<ContextMenu x:Key="RadioPartContextMenuExtended">
			<MenuItem Header="{x:Static properties:Globalization.RadioPart_ContextMenu_Play}" Click="contextMenuPlay_Click"/>
			<MenuItem Header="{x:Static properties:Globalization.RadioPart_ContextMenu_Remove}" Click="contextMenuRemove_Click"/>
			<MenuItem Header="{x:Static properties:Globalization.RadioPart_ContextMenu_Edit}" Click="contextMenuEdit_Click"/>
		</ContextMenu>

		<!-- Link style -->
		<Style x:Key="CellValuePresenter_LinkStyle" TargetType="{x:Type igDP:CellValuePresenter}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
						<TextBlock VerticalAlignment="Center"
													   HorizontalAlignment="Left"
													   Cursor="Hand"
													   Foreground="{DynamicResource VOColor03}"
													   TextDecorations="Underline"
													   Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record.DataItem.SiteUrl}">
						</TextBlock>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<!-- The radio level must be translated to the right -->
		<Style TargetType="{x:Type igDP:ExpandableFieldRecordPresenter}">
			<Setter Property="Padding" Value="30,0,0,0" />
		</Style>

		<!-- The "+" "-" to group sub levels -->
		<Style TargetType="{x:Type igWindows:ExpansionIndicator}">
			<Setter Property="Margin" Value="5,0,5,0" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type igWindows:ExpansionIndicator}">
						<Grid Width="12" Height="12" x:Name="grdExpansionIndicatorClosed" RenderTransformOrigin="0.5,0.5" SnapsToDevicePixels="True">
							<Path
															x:Name="ExpandPath"
															StrokeThickness="1"
															Stroke="#00CCCCCC" Fill="{DynamicResource VOColorIcon}"
															HorizontalAlignment="Left"
															VerticalAlignment="Center"
															Margin="1,1,1,1"
															Width="7"
															Height="10"
															RenderTransformOrigin="0.5,0.5"
															Stretch="Fill"
															Data="M60,40 L60,20 70,30 z"
															Cursor="{TemplateBinding Cursor}">
								<Path.RenderTransform>
									<TransformGroup>
										<RotateTransform Angle="0" />
									</TransformGroup>
								</Path.RenderTransform>
							</Path>
						</Grid>

						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="True">
								<Setter TargetName="ExpandPath" Property="RenderTransform">
									<Setter.Value>
										<TransformGroup>
											<RotateTransform Angle="90" />
										</TransformGroup>
									</Setter.Value>
								</Setter>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<!-- Remove the horizontal scrollbar -->
		<Style TargetType="{x:Type igDP:RecordListControl}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type igDP:RecordListControl}">
						<ScrollViewer
												CanContentScroll="True"
												Focusable="False"
												HorizontalScrollBarVisibility="Hidden"
												VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}">
							<ItemsPresenter/>
						</ScrollViewer>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

	</runtime:VisualPart.Resources>

	<runtime:VisualPart.RenderTransform>
		<TransformGroup>
			<ScaleTransform ScaleX="1" ScaleY="1" />
			<RotateTransform Angle="0" />
			<TranslateTransform X="0" Y="0" />
		</TransformGroup>
	</runtime:VisualPart.RenderTransform>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="30"/>
			<RowDefinition />
		</Grid.RowDefinitions>

		<!-- Tool bar -->
		<Border Margin="2,2,2,2" Background="{DynamicResource VOColor11}" CornerRadius="1" Opacity="0.5"/>
		<DockPanel Margin="7,0,7,0">

			<StackPanel Orientation="Horizontal" Height="30">
				<Button x:Name="btnAddRadio" Margin="5,2,5,2" Style="{DynamicResource Button.TransparentWithEffect2}">
					<StackPanel Orientation="Horizontal">
						<wpf:Icon Source="/_images/PartRadio/add.png" Width="18" Height="18"/>
						<TextBlock Text="{x:Static properties:Globalization.RadioPart_Add}" Margin="5,0,5,0" VerticalAlignment="Center"/>
					</StackPanel>
				</Button>
				<Button x:Name="btnRemoveRadio" Margin="5,2,5,2" Style="{DynamicResource Button.TransparentWithEffect2}">
					<StackPanel Orientation="Horizontal">
						<wpf:Icon Source="/_images/PartRadio/remove.png" Width="18" Height="18"/>
						<TextBlock Text="{x:Static properties:Globalization.RadioPart_Remove}" Margin="5,0,5,0" VerticalAlignment="Center"/>
					</StackPanel>
				</Button>
				<Button x:Name="btnEditRadio" Margin="5,2,5,2" Style="{DynamicResource Button.TransparentWithEffect2}">
					<StackPanel Orientation="Horizontal">
						<wpf:Icon Source="/_images/PartRadio/edit.png" Width="18" Height="18"/>
						<TextBlock Text="{x:Static properties:Globalization.RadioPart_Edit}" Margin="5,0,5,0" VerticalAlignment="Center"/>
					</StackPanel>
				</Button>
			</StackPanel>
			<Grid>
				<TextBlock x:Name="txtCannotConnect" Text="Cannot connect to this radio channel" Foreground="#FFC10000" FontWeight="Bold" HorizontalAlignment="Right" VerticalAlignment="Center" Visibility="Hidden" Margin="0,0,15,0"/>

				<Rectangle x:Name="recProcessing" RadiusX="2" RadiusY="2" ClipToBounds="True" Width="100" Height="10" Visibility="Hidden" HorizontalAlignment="Right" Margin="0,0,15,0">
					<Rectangle.Fill>
						<DrawingBrush TileMode="Tile" Stretch="None" Viewbox="0,0,1,1" Viewport="0,0,25,25" ViewportUnits="Absolute">
							<DrawingBrush.RelativeTransform>
								<TranslateTransform X="0" Y="0" />
							</DrawingBrush.RelativeTransform>
							<DrawingBrush.Drawing>
								<GeometryDrawing Geometry="M10,0 25,0 15,25 0,25 Z">
									<GeometryDrawing.Brush>
										<LinearGradientBrush StartPoint="4.88101e-008,0.5" EndPoint="1,0.5">
											<GradientStop Color="#FF555555" Offset="0"/>
											<GradientStop Color="#FF555555" Offset="1"/>
										</LinearGradientBrush>
									</GeometryDrawing.Brush>
								</GeometryDrawing>
							</DrawingBrush.Drawing>
						</DrawingBrush>
					</Rectangle.Fill>
					<Rectangle.Triggers>
						<EventTrigger RoutedEvent="FrameworkElement.Loaded">
							<BeginStoryboard>
								<Storyboard>
									<DoubleAnimation Storyboard.TargetProperty="(Shape.Fill).(Brush.RelativeTransform).(TranslateTransform.X)" From="0" To=".25" RepeatBehavior="Forever" Duration="0:0:1" />
								</Storyboard>
							</BeginStoryboard>
						</EventTrigger>
					</Rectangle.Triggers>
				</Rectangle>

			</Grid>
		</DockPanel>

		<!-- Grid -->
		<igDP:XamDataGrid x:Name="xdgGenres" Background="Transparent" Grid.Row="1" IsGroupByAreaExpanded="False" IsNestedDataDisplayEnabled="True" GroupByAreaLocation="None" ScrollingMode="Immediate" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
			<igDP:XamDataGrid.FieldLayouts>
				<igDP:FieldLayout Key="RadioGenre">
					<igDP:FieldLayout.Settings>
						<igDP:FieldLayoutSettings HighlightAlternateRecords="True" SelectionTypeRecord="Single" SelectionTypeField="None" SelectionTypeCell="None" AutoGenerateFields="False" AllowDelete="False"/>
					</igDP:FieldLayout.Settings>
					<igDP:FieldLayout.Fields>
						<igDP:Field Name="Title" Label="{x:Static properties:Globalization.RadioPart_Title}">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelWidth="3000" CellWidth="3000"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Radios"/>
					</igDP:FieldLayout.Fields>
				</igDP:FieldLayout>
				<igDP:FieldLayout Key="Radio">
					<igDP:FieldLayout.SortedFields>
						<igDP:FieldSortDescription FieldName="Priority"/>
					</igDP:FieldLayout.SortedFields>
					<igDP:FieldLayout.Settings>
						<igDP:FieldLayoutSettings LabelLocation="Hidden" HighlightAlternateRecords="True" SelectionTypeRecord="Single" SelectionTypeField="None" SelectionTypeCell="None" AutoGenerateFields="False" AllowDelete="False"/>
					</igDP:FieldLayout.Settings>
					<igDP:FieldLayout.Fields>
						<igDP:Field Name="Priority" Label="Priority" Visibility="Collapsed" >
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelWidth="300"  CellWidth="300"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="RadioIcon" Label="">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellMinWidth="20" CellMaxWidth="20" CellWidth="20"
												  CellValuePresenterStyle="{StaticResource xdpIconSourceCellValuePresenter}" CellClickAction="SelectRecord" AllowResize="False" LabelWidth="20" LabelMaxWidth="20" LabelMinWidth="20"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Title" Label="{x:Static properties:Globalization.RadioPart_Title}">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelWidth="300"  CellWidth="300"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="BitRate" Label="{x:Static properties:Globalization.RadioPart_BitRate}">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelMinWidth="50" CellMinWidth="50"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="SiteUrl" Label="{x:Static properties:Globalization.RadioPart_SiteURL}">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelMinWidth="150" CellMinWidth="150" CellValuePresenterStyle="{StaticResource CellValuePresenter_LinkStyle}"/>
							</igDP:Field.Settings>
						</igDP:Field>
						<igDP:Field Name="Description" Label="{x:Static properties:Globalization.RadioPart_Description}">
							<igDP:Field.Settings>
								<igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" LabelMinWidth="3000" CellMinWidth="3000"/>
							</igDP:Field.Settings>
						</igDP:Field>
					</igDP:FieldLayout.Fields>
				</igDP:FieldLayout>
			</igDP:XamDataGrid.FieldLayouts>
		</igDP:XamDataGrid>

	</Grid>
</runtime:VisualPart>
